package com.base.interview.devtest.api;

import com.base.interview.devtest.model.ResponseModel;
import com.base.interview.devtest.model.dto.PostDTO;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/api/posts")
public interface IPostApi {
    @ApiOperation(value = "Create Post", nickname = "createPost", response = ResponseModel.class, tags = {"post"})
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "OK", response = ResponseModel.class),
            @ApiResponse(code = 401, message = "Authorization Required", response = ResponseModel.class),
            @ApiResponse(code = 403, message = "Authorization Failed", response = ResponseModel.class),
            @ApiResponse(code = 500, message = "Internal Server Error", response = ResponseModel.class)
    })
    @PostMapping()
    ResponseEntity<ResponseModel> create(@RequestBody PostDTO postDTO);

    @ApiOperation(value = "List All Post", nickname = "listAllPosts", response = ResponseModel.class, tags = {"post"})
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "OK", response = ResponseModel.class),
            @ApiResponse(code = 401, message = "Authorization Required", response = ResponseModel.class),
            @ApiResponse(code = 403, message = "Authorization Failed", response = ResponseModel.class),
            @ApiResponse(code = 500, message = "Internal Server Error", response = ResponseModel.class)
    })
    @GetMapping()
    ResponseEntity<ResponseModel> listAll();

    @ApiOperation(value = "List User's Post", nickname = "listPostsByUser", response = ResponseModel.class, tags = {"post"})
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "OK", response = ResponseModel.class),
            @ApiResponse(code = 401, message = "Authorization Required", response = ResponseModel.class),
            @ApiResponse(code = 403, message = "Authorization Failed", response = ResponseModel.class),
            @ApiResponse(code = 500, message = "Internal Server Error", response = ResponseModel.class)
    })
    @GetMapping("/{userId}")
    ResponseEntity<ResponseModel> listByUser(@PathVariable(name = "userId") Long userId);
}
